﻿using System;
using System.Threading;
using System.Windows.Forms;

namespace tiny_compiler
{
	public static class CopyToClipboard
	{
		public static void Copy(string _text)
		{
			Exception threadEx = null;
			ThreadStart threadStart = new ThreadStart(
				delegate
				{
					try
					{
						Clipboard.Clear();
						Clipboard.SetText(_text);
					}
					catch (Exception ex)
					{
						threadEx = ex;
					}
				});
			Thread staThread = new Thread(threadStart);
			staThread.SetApartmentState(ApartmentState.STA);
			staThread.Start();
			staThread.Join();

			Console.Beep();
		}
	}
}
